package com.wandian.ui.translation
{
	import com.wandian.ui.controls.ContentController;
	
	import flash.text.*;

	public class TranslationAsset extends ContentController
	{
		protected var fAssetDescription_tad:TranslationAssetDescription;
		protected var fTextField_tf:TextField;

		public function TranslationAsset(param1:String)
		{
			this.assetDescription=TranslationController.getInstance().getAssetDescriptionById(param1);
			return;
		} // end function

		protected function get assetDescription():TranslationAssetDescription
		{
			return this.fAssetDescription_tad;
		} // end function

		protected function set assetDescription(param1:TranslationAssetDescription):void
		{
			this.fAssetDescription_tad=param1;
			this.onAssetDescriptionUpdated();
			return;
		} // end function

		protected function onAssetDescriptionUpdated():void
		{
			this.contentX=this.assetDescription.assetX;
			this.contentY=this.assetDescription.assetY;
			if (this.assetDescription.assetUrl)
			{
				this.contentToUseName=this.assetDescription.assetUrl;
			}
			else
			{
				this.tryToUsePlaceholderAsContent();
			}
			if (this.assetDescription.assetType == TranslationAssetDescription.ASSET_TYPE_TEXT)
			{
				this.assetDescription.updateTextField(this.textField);
			}
			return;
		} // end function

		protected function initTextField():void
		{
			if (this.fTextField_tf)
			{
				return;
			}
			if (this.content["text_tf"])
			{
				this.fTextField_tf=this.content["text_tf"];
			}
			else
			{
				this.fTextField_tf=new TextField();
				this.content.addChild(this.textField);
			}
			return;
		} // end function

		protected function get textField():TextField
		{
			if (!this.fTextField_tf)
			{
				this.initTextField();
			}
			return this.fTextField_tf;
		} // end function

	}
}
